package saint.manager;

public class UnitConvert {
	 // Unit Type
	 public static final int MILES_PER_HOUR = 0;	
	 public static final int MILES_PER_SEC = 1;
	 public static final int YARD_PER_SEC = 2;
	 public static final int FEET_PER_SEC = 3;
	 public static final int KM_PER_HOUR = 4;
	 public static final int KM_PER_SEC = 5;
	 public static final int M_PER_SEC = 6;
	 public static final int KNOT = 7;
	 
	 public static final int METER = 0;
	 public static final int KILOMETER = 1;
	 public static final int MILE = 2;
	 public static final int YARD = 3;
	 public static final int FOOT = 4;
	 // Unit factor
	 public static final double SPEED_FACTOR[] = { 2.2369, 0.0006, 1.0936, 3.2808, 3.6, 0.001, 1, 1.9438 };
	 public static final double DISTANCE_FACTOR[] = { 1, 0.001, 0.0006, 1.094, 3.281 } ;
	 // Unit string
	 public static final String SPEED_UNIT_STRING[] = { "mi/h", "mi/s", "yd/s", "ft/s", "km/h", "km/s", "m/s", "kn" };
	 public static final String DISTANT_UINT_STRING[] = { "m", "km", "mile", "yd", "ft" }; 
	 // Unit convert method
	 public static double ConvertSpeed(float value, int convert_type) {
		double speed;
		if(convert_type > 7) {
			return 0;
		}
		speed = value * SPEED_FACTOR[convert_type];
		return speed;		
	 }
	
	 public static double ConvertDistance(double value, int convert_type) {
		 double distance;
		 if(convert_type > 4) {
			 return 0;
		 }
		 distance = value * DISTANCE_FACTOR[convert_type];
		 return distance;
		
	 }
	 
}
